<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>跳蚤市场</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <style type="text/css">
        .icon {
            width: 1em;
            height: 1em;
            vertical-align: -0.15em;
            fill: currentColor;
            overflow: hidden;
        }
    </style>

    <link href="__TMPL__/public/assets/wuye/css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="__TMPL__/public/assets/wuye/css/app.css" />
    <script src="__TMPL__/public/assets/wuye/js/iconfont.js"></script>
    <link href="__TMPL__/public/assets/wuye/css/mui.picker.css" rel="stylesheet" />
    <link href="__TMPL__/public/assets/wuye/css/mui.poppicker.css" rel="stylesheet" />
    <script src="__TMPL__/public/assets/wuye/js/mui.min.js"></script>
    <script src="__TMPL__/public/assets/wuye/js/iconfont.js"></script>
    <script src="__TMPL__/public/assets/wuye/js/mui.picker.js"></script>
    <script src="__TMPL__/public/assets/wuye/js/mui.poppicker.js"></script>
    <script src="__TMPL__/public/assets/wuye/js/mui.zoom.js"></script>
    <script src="__TMPL__/public/assets/wuye/js/mui.previewimage.js"></script>
    <script src="__TMPL__/public/assets//js/jquery-1.10.2.min.js"></script>
</head>

<body>

<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title"></h1>
</header>
{:widget('Wuye/nav')}
<div class="mui-content">
    <div class="mui-card">
        <div class="mui-card-header mui-card-media" style="height: 100px;">
            <div style="float: left;border-radius:70%; height: 80px; overflow:hidden;">
                <img class="mui-icon-image" src="{$data.headimgurl|default=''}" style="height: 80px;" />
            </div>
            <div class="mui-media-body" style="margin-left: 100px;margin-top: 15px;line-height: 22px;">
                <notempty name="$data['remark']">
                    {$data.remark|default=''}
                    <else/>
                    {$data.nickname|default=''}
                </notempty>
                <p>发表于 <?php echo date('Y-m-d H:i:s',$data['time'])?> </p>
                <p style="color: #444">位于 {$data.wxName}</p>
            </div>
        </div>
        <div class="mui-card-content" style="padding: 10px;">
            <p style="font-size: 17px;color: red;font-weight: 800;margin-top: 10px;">{$data['jiage']?='￥'.$data['jiage']} </p>
            <p>{$data.content|default=''}</p>
            <?php $img = explode(',',$data['imgsrc']);$cout = count($img);?>
            <volist name="img" id="img">
                <img src="<?php echo cmf_get_image_url($img);?>" data-preview-src="" data-preview-group="{$data.id}" style="max-width: 100%;width: 100%;">
            </volist>
        </div>
        <div class="mui-card-footer">
            <a class="mui-card-link" href="javascript:;" id="zan{$data.id}"><span class="mui-icon"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-good"></use></svg></span>赞({$data.zan|default='0'})</a>
            <a class="mui-card-link"></a>
            <a href="javascript:;" class="mui-card-link" id="huifu{$data.id}"><i class="mui-icon mui-icon-chatboxes"></i>回复</a>
        </div>
        <div class="mui-input-row" id="reply{$data.id}" style="display: none;">
            <input type="text" placeholder="请输入内容" style="width:80%;" id="content{$data.id}">
            <button class="mui-btn mui-btn-primary" id="queren{$data.id}">确认</button>
        </div>
        <ul class="mui-table-view" id="ul{$data.id}">
            {:widget('Wuye/marketHuifu', ['market_id'=>$data.id])}
        </ul>
        <script>
            mui("#huifu{$data.id}")[0].addEventListener("tap",function(){
                $("#reply{$data.id}").toggle();
            });
            mui("#zan{$data.id}")[0].addEventListener("tap",function(){

                var zan{$data.id} = document.getElementById("zan{$data.id}");
                var id = {$data.id};
                mui.ajax("{:url('portal/wuye/marketZan')}",{
                    data:{'id':id},
                    dataType:'json',//服务器返回json格式数据
                    type:'post',//HTTP请求类型
                    timeout:10000,//超时时间设置为10秒；
                    headers:{'Content-Type':'application/json'},
                    success:function(data){
                        if(data.code == 0){
                            mui.toast(data.msg);
                        }else{
                            mui.toast(data.msg);
                            zan{$data.id}.innerHTML = '<span class="mui-icon"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-good"></use></svg></span>赞('+data.data.zan+')';
                        }
                    },
                    error:function(xhr,type,errorThrown){
                        //异常处理；
                        console.log(type);
                    }
                });
            });
            mui("#queren{$data.id}")[0].addEventListener("tap",function(){
                var id = {$data.id};
                var content = document.getElementById("content{$data.id}").value;
                var ul = document.getElementById("ul{$data.id}");
                mui.ajax("{:url('portal/wuye/marketHuifu')}",{
                    data:{id:id,content:content},
                    dataType:'json',//服务器返回json格式数据
                    type:'post',//HTTP请求类型
                    timeout:10000,//超时时间设置为10秒；
                    headers:{'Content-Type':'application/json'},
                    success:function(data){
                        if(data.code == 1){
                            mui.toast(data.msg);
                            ul.innerHTML += '<li class="mui-table-view-cell mui-media" >\n' +
                                '                        <a href="javascript:;">\n' +
                                '                            <img class="mui-media-object mui-pull-left" src="'+data.data.headimgurl+'">\n' +
                                '                            <div class="mui-media-body">\n' +
                                '                                <p class=\'mui-ellipsis\'>'+content+'</p>\n' +
                                '                            </div>\n' +
                                '                        </a>\n' +
                                '                    </li>';
                            location.reload()

                        }
                    },
                    error:function(xhr,type,errorThrown){
                        //异常处理；
                        console.log(type);
                    }
                });
            });
        </script>
    </div>
</div>
</body>
</html>